package com.xiangwuyue.exam.controller;


import com.xiangwuyue.exam.pojo.User;

import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;



@RestController
@RequestMapping("/users")
public class UserController {
    /**
     * @description  前端使用form表达Post方式，传递“username”、“password”属性，后端controller接收并打印
     * @author  xiangwuyue
     * @date     下午 03:25
     * @param	user	
     * @return  void
    */
    @PostMapping("/login")
    public String login(@RequestBody User user){

        System.out.println("用户名:"+user.getUsername());
        System.out.println("-----------------------------------------------------------------");
        System.out.println("密码:"+user.getPassword());
        return "SUCCESS";
    }
    /**
     * @description  前端通过url，使用“?、&”符号拼接，传递参数“username”、“password”属性，后端controller接收并打印
     * @author  xiangwuyue
     * @date     下午 03:25
     * @param	username	
     * @param	password	
     * @return  java.lang.String
    */
    @GetMapping
    public String login1( @RequestParam("username") String username,
                          @RequestParam("password") String password){
        System.out.println("用户名:"+username);
        System.out.println("-----------------------------------------------------------------");
        System.out.println("密码:"+password);
        return "SUCCESS";
    }

}
